﻿/*!	@file	r_script_xtal.h
	@brief	xtalの管理クラス
Copyright (c) 2010 Yuya Yamaguchi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _R_SCRIPT_XTAL_H_
#define _R_SCRIPT_XTAL_H_


#include "../../rtti/r_rtti_class_base.h"

#ifdef R_SCRIPT_USE_XTAL

#include "../../util/r_util_singleton.h"
#include "../../alloc/r_alloc_allocator.h"

#include <xtal.h>
#include <xtal_macro.h>

#include <xtal_lib/xtal_cstdiostream.h>
#include <xtal_lib/xtal_winthread.h>
#include <xtal_lib/xtal_winfilesystem.h>
#include <xtal_lib/xtal_chcode.h>
#include <xtal_lib/xtal_errormessage.h>

#include "r_script_xtal_allocator.h"

//! スクリプトセットアップクラス
/*! r_config.hの
#define R_SCRIPT_USE_XTAL
が有効な場合xtalの初期化処理が行われます
*/
class cRScriptXtal : public r::rtti::ClassBase
{
	RRTTI_REFLECTION_DECLARE
	RSINGLETONTGET_DECLARE ( cRScriptXtal )
	RALLOC_PLACEMENT_NEW_DELETE_DEF ( eRAllocDef_Script )
public:
	//! コンストラクタ
	cRScriptXtal();
	//! デストラクタ
	virtual ~cRScriptXtal();
protected:
private:
	// allocatorはfutharkのを使用
	cRScriptXtalAllocator		allocLib;

	// 取り敢えずwindows環境(ココは将来的にライブラリをラップしたいなぁ...
#if R_TARGET_COMMON_WINDOWS
	xtal::CStdioStdStreamLib	stdLib;
	xtal::WinThreadLib			threadLib;
//	xtal::WinFilesystemLib		fileSystemLib;
#else
#endif // R_TARGET_COMMON_WINDOWS

	// 文字コード連動(ココも将来的にライブラリをラップ...
#ifdef R_USE_WCHAR
	xtal::UTF16ChCodeLib		charCodeLib;
#else
	xtal::SJISChCodeLib			charCodeLib;
#endif
};

#endif // R_SCRIPT_USE_XTAL

#endif // _R_SCRIPT_XTAL_H_
